Use revert-buffer-restore-functions in xref-revert-buffer (bug#49731)
authorJuri Linkov <juri@linkov.net>
Wed, 5 Jun 2024 06:35:50 +0000 (09:35 +0300)
committerJuri Linkov <juri@linkov.net>
Wed, 5 Jun 2024 06:35:50 +0000 (09:35 +0300)
* lisp/progmodes/xref.el (xref-revert-buffer):
When 'revert-buffer-restore-functions' is bound,
use it in the same way as in 'revert-buffer'.

lisp/progmodes/xref.el

index beea2b8c1d6833ec1fb258e8fa19ce1fd4a8d088..fb6c9dad73b320757f35a7aff4ecdc49b118245b 100644 (file)
@@ -1277,13 +1277,18 @@ Return an alist of the form ((GROUP . (XREF ...)) ...)."
   "Refresh the search results in the current buffer."
   (interactive)
   (let ((inhibit-read-only t)
-        (buffer-undo-list t))
+        (buffer-undo-list t)
+        restore-functions)
+    (when (boundp 'revert-buffer-restore-functions)
+      (run-hook-wrapped 'revert-buffer-restore-functions
+                        (lambda (f) (push (funcall f) restore-functions) nil)))
     (save-excursion
       (condition-case err
           (let ((alist (xref--analyze (funcall xref--fetcher)))
                 (inhibit-modification-hooks t))
             (erase-buffer)
-            (xref--insert-xrefs alist))
+            (prog1 (xref--insert-xrefs alist)
+              (mapc #'funcall (delq nil restore-functions))))
         (user-error
          (erase-buffer)
          (insert